package java11;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class EnhancedStringTest {
    public static void main(String[] args) throws IOException, InterruptedException, URISyntaxException {


        var str = "AB\nC\nD";
        System.out.println(str.isBlank());    //判断是否字符串为空或者是仅包含空格
        str.lines()   //根据\n换行符进行切割，分为多个字符串，并转换为Stream进行操作
           .forEach(System.out::println);

        //重复字符串拼接
        String str1 = "ABCD";
        System.out.println(str1.repeat(2));

        //去除空格
        String str3 = " A B C D ";
        System.out.println(str3.strip());   //去除首尾空格
        System.out.println(str3.stripLeading());  //去除首部空格
        System.out.println(str3.stripTrailing());   //去除尾部空格

        HttpClient client = HttpClient.newHttpClient();   //创建HttpClient
        //构造一个Http请求实体
        HttpRequest request = HttpRequest.newBuilder().uri(new URI("https://yuanyou.blog.csdn.net")).build();
        //send方法后面还需要一个响应体处理器
        HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}
